import { fetchGet,fetchPost,fetchDelete } from '../utils/http'
import { BASE_URL } from '@/utils/host'
/**
 *竞赛所有赛事 
 */
export const allCompetitions= (params) => {
    return fetchGet("/competition/index",{status:params})
}

/**
 * 赛事详情
 */
export const competitionDetail = (params) => {
    return fetchGet("/competition/getCompetition",{competition_id:params})
}

/**
 * 赛事报名
 */
export const competitionSignUp = (params) => {
    return fetchPost(`/competitors/competitions/${params}`)
}

/**
 * 报名状态
 */
export const getUserSignUpStatus = (params) => {
    return fetchPost(`/competitors/competitions/${params}/status`)
}

/**
 * 提交文件
 */
export const submitFileUrl = () => {
    return `${BASE_URL}/data/competitionFileUpload`
}

/**
 * 组建团队
 */
export const createGroup = (params) => {
    return fetchPost("/competitors/group",{
       cmpId: params.cmpId,
       groupName:params.groupName,
       type:params.type
    })
}

/**
 * 赛事简介 
 */
export const getCompetitionInfo = (params) => {
    return fetchGet("/competition/getCompetitionInfo",{competition_id:Number(params)})
}

/**
 * 赛题与数据
 */
export const getCompetitionTopic = (params) => {
    return fetchGet('/competition/getCompetitionTopic',{competition_id:Number(params)})
}

/**
 * 竞赛文件下载
 */
export const downLoadCmpData = (params) => {
    return fetchGet("/data/downLoadCmpData",{data_id:Number(params)})
}

/**
 * 
 * 赛事文件列表
 */
export const getCompetitionDataList = (params) => {
    return fetchGet('/competition/getCompetitionDataList',{competition_id:Number(params)})
}

/**
 * 
 * 我的成绩
 */
export const getScores = (params) => {
    return fetchGet(`/competitors/competition/${Number(params)}/scores`)
}

/**
 * 
 * 我的团队
 */
export const getMyGroup = (params) => {
    return fetchGet("/competitors/group",{competition_id:Number(params)})
}

/**
 * 
 * 我的队员
 */
export const getGroupMember = (params) => {
    return fetchGet("/competitors/group/member",{group_id:Number(params)})
}

/**
 * 移除队员
 */
export const deleteMember = (params) => {
    return fetchDelete("/competitors/group/member",{group_id:Number(params.group_id),user_id:Number(params.user_id)})
}

/**
 * 邀请成员
 */
export const inviteMember = (params) => {
    return fetchPost("/competitors/group/member",params)
}

/**
 * 成员退出
 */
export const leaveGroup = (params) => {
    return fetchDelete("/competitors/group",{group_id:Number(params)})
}

/**
 * 排行榜
 */
export const rankList = (params) => {
    return fetchGet("/competition/groups/rank-list",{competition_id:Number(params)})
}

/**
 * 校验结果或代码是否提交
 */
export const checkupLoad = () => {
    return fetchGet("/competition/checkupload")
}

/**
 * 校验赛事数据是否上传
 */
export const checkCompetitionData = (params) => {
    return fetchGet("/competition/checkCompetitionData")
}

/**
 * 论坛列表
 */
export const compDiscussList = (params) => {
    return fetchGet("/competition/comments/list",{competitionId:params})
}

/**
 * 论坛评论删除
 */
export const compDiscussDel = (params) => {
    return fetchGet("/competition/comments/delete",{commentsId:params})
}

/**
 * 论坛评论添加
 */
export const compDiscussAdd = (params) => {
    return fetchPost("/competition/comments/add",{
        competitionId:params.competitionId,
        content: params.content
    })
}

/**
 * 论坛评论点赞
 */
export const compDiscussVote = (params) => {
    return fetchGet("/competition/comments/vote",{commentsId:params})
}

/**
 * 评论回复列表
 */
export const compDiscussReply = (params) => {
    return fetchGet("/competitionReply/list",{commentsId:params})
}

/**
 * 回复
 */
export const compDiscussReplyAdd = (params) => {
    return fetchPost("/competitionReply/add",{
        isChild: 0,
        commentsId:params.commentsId,
        content: params.content
    })
}